
from math import sqrt

def is_triangle(c):
    n = int(sqrt(2 * c + 0.25) - 0.5)
    return n * (n + 1) == c * 2

for i in range(10):
    print i, is_triangle(i)

s = open('42.words.txt', 'rb').read()
# to tuple of words
s = eval(compile('(' + s + ')', '<string>', 'eval'))
# to lower
s = map(lambda w:w.lower(), s)
# to number
s = map(lambda w:sum(map(lambda c: ord(c) - ord('a') + 1, w)), s)
# if triangle
print len(filter(is_triangle, s))